package com.csu.mining.adapters;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.csu.mining.R;
import com.csu.mining.activity.DocumentActivity;
import com.csu.mining.activity.VideoAndDocumentActivity;
import com.csu.mining.views.WEqualsHImageView;

import java.util.ArrayList;
import java.util.List;

public class MiningFileAdapter extends RecyclerView.Adapter<MiningFileAdapter.ViewHolder>{

    private Context mContext;
    private int[] texts = {
            R.string.way1,R.string.way2,R.string.way3,R.string.way4,R.string.way5,R.string.way6,R.string.way7,R.string.way8
    };

    private List<Integer> listText = new ArrayList<>();

    public MiningFileAdapter(Context context){
        mContext = context;
        for(int i=0;i<8;i++){
            listText.add(texts[i]);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_grid_file,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
        holder.textView.setText(listText.get(position));
        holder.textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.putExtra("order",position);
                intent.setClass(mContext, DocumentActivity.class);
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 8;
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        public TextView textView;
        public WEqualsHImageView wEqualsHImageView;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            textView = (TextView)itemView.findViewById(R.id.file_text);
        }
    }
}
